package com.zhilianbao.leyaogo.http.api;

import android.content.Context;

import com.zhilianbao.leyaogo.constants.HttpConfig;
import com.zhilianbao.leyaogo.http.client.LeYaoGoClient;
import com.zhilianbao.okhttputils.callback.Callback;
import com.zhilianbao.okhttputils.model.JsonParams;


/**
 * Author: hcy
 * Description:收货地址
 * Created: 2016/11/18 10:35
 */
public class AddressApi {

    /**
     * 增加收货地址
     */
    public static final String I_METHOD_ADD_ADDRESS = "order/addUserAddress";

    /**
     * 删除收货地址
     */
    public static final String I_METHOD_DEL_ADDRESS = "order/delUserAddress";

    /**
     * 获取收货地址
     */
    public static final String I_METHOD_GET_ADDRESS = "order/getUserAddress";

    /**
     * 修改收货地址
     */
    public static final String I_METHOD_UPDATE_ADDRESS = "order/updateUserAddress";

    /**
     * 增加，修改收货地址
     * @param context
     * @param userId     用户id
     * @param supplierId 运营商id
     * @param isDefault  是否默认0否 1是
     * @param adName     收货人
     * @param adPhone    收货联系电话
     * @param province   省
     * @param city       市
     * @param area       区
     * @param strAddress 详细地址
     * @param callback
     */
    public static void addAddress(Context context, long userId, long supplierId, int isDefault,
                                  String adName, String adPhone, String province, String city, String area, String strAddress,String address, Callback callback) {

        JsonParams jsonParams = new JsonParams();
        jsonParams.put("userId", userId);
        jsonParams.put("supplierId", supplierId);
        jsonParams.put("isDefault", isDefault);
        jsonParams.put("adName", adName);
        jsonParams.put("adPhone", adPhone);
        jsonParams.put("province", province);
        jsonParams.put("city", city);
        jsonParams.put("area", area);
        jsonParams.put("strAddress", strAddress);
        jsonParams.put("address", address);
        LeYaoGoClient.post(context, HttpConfig.BASE_URL + I_METHOD_ADD_ADDRESS, jsonParams, callback);
    }

    /**
     * 增加，修改收货地址
     * @param context
     * @param userId     用户id
     * @param supplierId 运营商id
     * @param addressId  地址id，
     * @param isDefault  是否默认0否 1是
     * @param adName     收货人
     * @param adPhone    收货联系电话
     * @param province   省
     * @param city       市
     * @param area       区
     * @param strAddress 详细地址
     * @param callback
     */
    public static void updateAddress(Context context, long userId, long supplierId, long addressId, int isDefault,
                                  String adName, String adPhone, String province, String city, String area, String strAddress, String address, Callback callback) {

        JsonParams jsonParams = new JsonParams();
        jsonParams.put("userId", userId);
        jsonParams.put("supplierId", supplierId);
        jsonParams.put("addressId", addressId);
        jsonParams.put("isDefault", isDefault);
        jsonParams.put("adName", adName);
        jsonParams.put("adPhone", adPhone);
        jsonParams.put("province", province);
        jsonParams.put("city", city);
        jsonParams.put("area", area);
        jsonParams.put("strAddress", strAddress);
        jsonParams.put("address", address);

        LeYaoGoClient.post(context, HttpConfig.BASE_URL + I_METHOD_UPDATE_ADDRESS, jsonParams, callback);
    }

    /**
     * 删除收货地址
     * @param context
     * @param userId 用户id
     * @param supplierId 运营商id
     * @param addressId 收货地址id
     * @param callback
     */
    public static void delAddress(Context context, long userId, long supplierId, long addressId, Callback callback) {
        JsonParams jsonParams = new JsonParams();
        jsonParams.put("userId", userId);
        jsonParams.put("supplierId", supplierId);
        jsonParams.put("addressId", addressId);

        LeYaoGoClient.post(context, HttpConfig.BASE_URL + I_METHOD_DEL_ADDRESS, jsonParams, callback);
    }

    /**
     * 获取收货地址
     * @param context
     * @param userId
     * @param supplierId
     * @param type 获得类型 1 只返回一条默认用户地址数据
     * @param callback
     */
    public static void getAddress(Context context, long userId, long supplierId, int type, Callback callback){
        JsonParams jsonParams = new JsonParams();
        jsonParams.put("userId", userId);
        jsonParams.put("supplierId", supplierId);
        jsonParams.put("type", type);
        LeYaoGoClient.post(context, HttpConfig.BASE_URL + I_METHOD_GET_ADDRESS, jsonParams, callback);
    }


}
